package lee.vioson.ebook.utils

import android.content.Context
import java.io.File
import java.io.IOException

/**
 *Author:viosonlee
 *Date:2023/6/18
 *DESCRIPTION:
 */
@Throws(IOException::class)
fun Context.createChapterFile(bookId: String, chapterId: String, fileName: String): File {
    val filePath =
        StringBuffer().append(bookId).append(File.separator).append(chapterId).toString()
    val dir = File(filesDir, filePath)
    if (!dir.exists()) {
        dir.mkdirs()
    }
    return File(dir, fileName)
}

/**
 * default dir file of zip file
 */
val File.zipDefaultExtractDir: File
    get() = File(parentFile, "/extract")